home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date:
- // Author:
- //
-
- global proc switchPanes (string $doWhat, int $usePointer)
- {
- global string $gMainPane;
- global int $gPoppedPane = -1;
- global string $gPrePopConfig;
- global string $gPrePopControls[4];
- global int $gPrePopSizes[8];
- string $currPane;
-
- if ($gMainPane != "" && `paneLayout -exists $gMainPane`) {
- if ($doWhat == "goBack") {
- if (`panelHistory -q -isEmpty mainPanelHistory`) {
- //
- // No history so go to four view, but make sure current
- // camera is preserved.
- //
- string $currCam = "";
- string $currPanel = `getPanel -withFocus`;
- if ("modelPanel" == `getPanel -typeOf $currPanel`) {
- //
- // save the camera
- //
- $currCam = `modelPanel -q -cam $currPanel`;
- }
-
- string $config = `getPanel -cwl "Four View"`;
- if ("" != $config) {
- setNamedPanelLayout "Four View";
- } else {
- panelHistory -e -suspend on mainPanelHistory;
- paneLayout -e -cn "quad" $gMainPane;
- fillEmptyPanes;
- panelHistory -e -suspend off mainPanelHistory;
- }
-
- //
- // Make sure the previous camera view is represented
- //
- if ($currCam != "" && $currCam != "persp" && $currCam != "top" &&
- $currCam != "front" && $currCam != "side")
- {
- //
- // put camera in persp view
- //
- string $perspPanel = `getPanel -withLabel "Persp View"`;
- if (`modelPanel -exists $perspPanel`) {
- modelPanel -e -cam $currCam $perspPanel;
- }
- }
- } else {
- if ($gPoppedPane > 0) {
- //
- // Restore pre popped config
- //
- panelHistory -e -suspend on mainPanelHistory;
-
- $currPane = `paneLayout -q -p1 $gMainPane`;
- paneLayout -e -manage false $gMainPane;
- paneLayout -e -cn $gPrePopConfig $gMainPane;
-
- int $nArr = size($gPrePopSizes);
- if (`panel -exists $gPrePopControls[0]` &&
- !`panel -q -to $gPrePopControls[0]`
- )
- {
- if ("" == `panel -q -control $gPrePopControls[0]`) {
- //
- // parent the panel to the main pane first.
- //
- string $pType = `getPanel -typeOf $gPrePopControls[0]`;
- string $cmd = ($pType +" -e -parent $gMainPane "+
- $gPrePopControls[0]);
- eval $cmd;
- }
-
- paneLayout -e
- -sp $gPrePopControls[0] 1
- -ps 1 $gPrePopSizes[0] $gPrePopSizes[1]
- $gMainPane;
- } else {
- $gPrePopControls[0] = "";
- }
-
- if ($nArr > 3 && `panel -exists $gPrePopControls[1]` &&
- !`panel -q -to $gPrePopControls[1]`
- )
- {
- if ("" == `panel -q -control $gPrePopControls[1]`) {
- //
- // parent the panel to the main pane first.
- //
- string $pType = `getPanel -typeOf $gPrePopControls[1]`;
- string $cmd = ($pType +" -e -parent $gMainPane "+
- $gPrePopControls[1]);
- eval $cmd;
- }
-
- paneLayout -e
- -sp $gPrePopControls[1] 2
- -ps 2 $gPrePopSizes[2] $gPrePopSizes[3]
- $gMainPane;
- } else {
- $gPrePopControls[1] = "";
- }
-
- if ($nArr > 5 && `panel -exists $gPrePopControls[2]` &&
- !`panel -q -to $gPrePopControls[2]`
- )
- {
- if ("" == `panel -q -control $gPrePopControls[2]`) {
- //
- // parent the panel to the main pane first.
- //
- string $pType = `getPanel -typeOf $gPrePopControls[2]`;
- string $cmd = ($pType +" -e -parent $gMainPane "+
- $gPrePopControls[2]);
- eval $cmd;
- }
-
- paneLayout -e
- -sp $gPrePopControls[2] 3
- -ps 3 $gPrePopSizes[4] $gPrePopSizes[5]
- $gMainPane;
- } else {
- $gPrePopControls[2] = "";
- }
-
- if ($nArr > 7 && `panel -exists $gPrePopControls[3]` &&
- !`panel -q -to $gPrePopControls[3]`
- )
- {
- if ("" == `panel -q -control $gPrePopControls[3]`) {
- //
- // parent the panel to the main pane first.
- //
- string $pType = `getPanel -typeOf $gPrePopControls[3]`;
- string $cmd = ($pType +" -e -parent $gMainPane "+
- $gPrePopControls[3]);
- eval $cmd;
- }
-
- paneLayout -e
- -sp $gPrePopControls[3] 4
- -ps 4 $gPrePopSizes[6] $gPrePopSizes[7]
- $gMainPane;
- } else {
- $gPrePopControls[3] = "";
- }
-
-
- //
- // preserve current panel by placing it in the
- // popped pane. If current panel existed elsewhere
- // in the config then compensate.
- //
- int $swapped = -1;
- if ($currPane == $gPrePopControls[0]) {
- if ($gPoppedPane != 1) {
- paneLayout -e
- -sp $currPane $gPoppedPane
- $gMainPane;
- $swapped = 1;
- }
- } else if ($currPane == $gPrePopControls[1]) {
- if ($gPoppedPane != 2) {
- paneLayout -e
- -sp $currPane $gPoppedPane
- $gMainPane;
- $swapped = 2;
- }
- } else if ($currPane == $gPrePopControls[2]) {
- if ($gPoppedPane != 3) {
- paneLayout -e
- -sp $currPane $gPoppedPane
- $gMainPane;
- $swapped = 3;
- }
- } else if ($currPane == $gPrePopControls[3]) {
- if ($gPoppedPane != 4) {
- paneLayout -e
- -sp $currPane $gPoppedPane
- $gMainPane;
- $swapped = 4;
- }
- } else {
- paneLayout -e
- -sp $currPane $gPoppedPane
- $gMainPane;
- }
-
- if (0 < $swapped) {
- //
- // A pre-popped control has been swapped into the popped
- // pane. Try to swap positions if it is still a child.
- //
- string $childs[] = `paneLayout -q -ca $gMainPane`;
- for ($child in $childs) {
- if ($gPrePopControls[$gPoppedPane-1] == $child) {
- paneLayout -e
- -sp $child $swapped
- $gMainPane;
- }
- }
- }
-
- fillEmptyPanes;
-
- paneLayout -e -manage true $gMainPane;
- setFocus $currPane;
-
- panelHistory -e -suspend off mainPanelHistory;
- } else {
- panelHistory -e -back mainPanelHistory;
- }
- }
- } else {
- panelHistory -e -suspend on mainPanelHistory;
-
- if ($usePointer == 1) {
- $currPane = `paneLayout -q -pup $gMainPane`;
- if ("single" == $doWhat) {
- //
- // save pane state for popping.
- //
- $gPrePopControls[0] = `paneLayout -q -p1 $gMainPane`;
- $gPrePopControls[1] = `paneLayout -q -p2 $gMainPane`;
- $gPrePopControls[2] = `paneLayout -q -p3 $gMainPane`;
- $gPrePopControls[3] = `paneLayout -q -p4 $gMainPane`;
-
- if ($gPrePopControls[0] == $currPane) {
- $gPoppedPane = 1;
- } else if ($gPrePopControls[1] == $currPane) {
- $gPoppedPane = 2;
- } else if ($gPrePopControls[2] == $currPane) {
- $gPoppedPane = 3;
- } else if ($gPrePopControls[3] == $currPane) {
- $gPoppedPane = 4;
- } else {
- $gPoppedPane = 1;
- }
-
- $gPrePopSizes = `paneLayout -q -ps $gMainPane`;
- $gPrePopConfig = `paneLayout -q -cn $gMainPane`;
- }
- } else {
- $currPane = `getPanel -withFocus`;
- }
-
- // If there is no current panel then don't try to
- // switch to it.
- //
- if ($currPane != "") {
- paneLayout -e -cn $doWhat $gMainPane;
- if ($doWhat == "single") {
- paneLayout -e -setPane $currPane 1 $gMainPane;
- }
- setFocus `paneLayout -q -p1 $gMainPane`;
-
- fillEmptyPanes;
-
- }
-
- panelHistory -e -suspend off mainPanelHistory;
- }
- }
- }
-